package org.kzwl.book.controller.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.kzwl.comm.advice.BizException;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.QueryThearCategoryBO;
import org.kzwl.comm.utils.PagingCondition;
import org.kzwl.entity.web.CuHeritageCategory;
import org.kzwl.entity.web.ThearCategory;
import org.kzwl.service.web.ThearCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("风采展示分类")
@Slf4j
@RestController
@RequestMapping("/thearCategory")
public class ThearCategoryController {

    @Autowired
    ThearCategoryService thearCategoryService;

    @ApiOperation(value = "查询风采展示分类列表")
    @PostMapping("/queryList")
    public ResponseData<List<ThearCategory>> queryList(@RequestBody QueryThearCategoryBO queryThearCategoryBO)
    {
        return thearCategoryService.queryList(queryThearCategoryBO);
    }



    @PostMapping("/queryPage")
    public ResponseData<IPage<ThearCategory>> queryPage(@RequestBody QueryThearCategoryBO queryThearCategoryBO)
    {
        return thearCategoryService.queryPage(queryThearCategoryBO);
    }


    @PostMapping("/saveOne")
    public ResponseData<Void> saveOne(@RequestBody ThearCategory cuHeritageCategory)
    {
        if ("".equals(cuHeritageCategory.getCuThearCatName()))
        {
            throw new BizException("类别不能为空");
        }
        return thearCategoryService.saveOne(cuHeritageCategory);
    }

    @PostMapping("/updateOne")
    public ResponseData<Void> updateOne(@RequestBody ThearCategory cuHeritageCategory)
    {
        if ("".equals(cuHeritageCategory.getCuThearCatName()))
        {
            throw new BizException("类别不能为空");
        }
        return thearCategoryService.updateOne(cuHeritageCategory);
    }

    @PostMapping("/queryOne")
    public ResponseData<ThearCategory> queryOne(@RequestBody Long Id)
    {
        return thearCategoryService.queryOne(Id);
    }


    @PostMapping("/deleteId")
    public ResponseData<Void> deleteId(@RequestBody Long Id)
    {
        return thearCategoryService.deleteId(Id);
    }
}
